//
//  CommTools.m
//  TTAddressBook
//
//  Created by hubin on 11-12-19.
//  Copyright (c) 2011年 __MyCompanyName__. All rights reserved.
//

#import "CommTools.h"

@implementation CommTools

NSString * const kVersion = @"V1.0.2.0";

+ (Boolean)isNumberCharaterString:(NSString *)str
{
    NSCharacterSet *disallowedCharacters = [[NSCharacterSet characterSetWithCharactersInString:@"0123456789QWERTYUIOPLKJHGFDSAZXCVBNMqwertyuioplkjhgfdsazxcvbnm"] invertedSet];
    NSRange foundRange = [str rangeOfCharacterFromSet:disallowedCharacters];
    if (foundRange.location == NSNotFound) {
        NSLog(@"是数字和字母的集合");
        return YES;
    }
    return NO;
}

+ (Boolean)isNumberString:(NSString *)str
{
    NSCharacterSet *disallowedCharacters = [[NSCharacterSet characterSetWithCharactersInString:@"0123456789"] invertedSet];
    NSRange foundRange = [str rangeOfCharacterFromSet:disallowedCharacters];
    if (foundRange.location == NSNotFound) {
        NSLog(@"是数字集合");
        return YES;
    }
    return NO;
}

+ (Boolean)isSameday:(NSDate *)date1 Date2:(NSDate *)date2
{
    NSCalendar* calendar = [NSCalendar currentCalendar];
    unsigned unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit |  NSDayCalendarUnit;
    
    NSDateComponents* comp1 = [calendar components:unitFlags fromDate:date1];   
    NSDateComponents* comp2 = [calendar components:unitFlags fromDate:date2];    
    return [comp1 day] == [comp2 day] 
    &&[comp1 month] == [comp2 month] 
    &&[comp1 year] == [comp2 year];
}

+ (void)setButtonImage:(UIButton*)btn 
			normalpic:(NSString*)normalpic 
		  selectedpic:(NSString*)selectedpic 
		   disablepic:(NSString*)disablepic
{
	if (nil == btn)
	{
		return;
	}
	[btn setImage:nil forState:UIControlStateNormal];
	[btn setImage:nil forState:UIControlStateSelected];
	[btn setImage:nil forState:UIControlStateDisabled];
	
	[btn setImage:[UIImage imageNamed:normalpic] forState:UIControlStateNormal];
	[btn setImage:[UIImage imageNamed:selectedpic] forState:UIControlStateSelected];
	[btn setImage:[UIImage imageNamed:disablepic] forState:UIControlStateDisabled];
	[btn setBackgroundColor:[UIColor clearColor]];
	[btn setShowsTouchWhenHighlighted:YES];	
	
}



@end
